/**   
 * @Title: BaseResult.java 
 * @Package com.fnic.nsm.common.result 
 * @author li   
 * @date 2014年10月20日 下午5:03:55 
 * @version V1.0   
 */
package com.c.result;

import java.io.Serializable;

import flexjson.JSONSerializer;

public abstract class BaseResult<T> implements Serializable {
	/**
	 * @Fields serialVersionUID : TODO
	 */
	private static final long serialVersionUID = 8670031376283274251L;
	/** JSON Serializer */
	private JSONSerializer _jsonSer = new JSONSerializer().include("data").include("rows");
	/** If queried successfully */
	private boolean success;
	/** Query result comments */
	private String message;

	public abstract BaseResult<T> appendJsonIncludes(String... propNames);

	public abstract BaseResult<T> appendJsonExcludes(String... propNames);

	/**
	 * BaseResult's constructor
	 */
	public BaseResult() {
		super();
	}

	/**
	 * BaseResult's constructor
	 * 
	 * @param success
	 * @param message
	 */
	public BaseResult(boolean success, String message) {
		super();
		this.success = success;
		this.message = message;
	}

	/**
	 * print the result by json string
	 */
	public String toString() {
		return _jsonSer.serialize(this);
	}

	public String toString(String... strInclude) {
		return _jsonSer.include(strInclude).serialize(this);
	}

	/* getter and setter... */
	public JSONSerializer get_jsonSer() {
		return _jsonSer;
	}

	public void set_jsonSer(JSONSerializer _jsonSer) {
		this._jsonSer = _jsonSer;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
}
